package com.lsk.netdisk.gateway.models;

import lombok.AllArgsConstructor;
import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import javax.servlet.http.Cookie;
import javax.servlet.http.HttpServletResponse;
import java.util.Map;

@Getter
@Setter
@AllArgsConstructor
@NoArgsConstructor
public class Response {
	private Object respData;
	private Map<String,String> respCookies;

	public void addCookie(String name,String value){
		respCookies.put(name,value);
	}
	public void addToResp(HttpServletResponse resp){
		if(respCookies == null){
			return;
		}
		for (Map.Entry<String,String> entry : respCookies.entrySet()){
			Cookie cookie = new Cookie(entry.getKey(),entry.getValue());
			resp.addCookie(cookie);
		}
	}
}
